package homwork;

import java.util.NavigableMap;

public class Money {
    public static void main(String[] args) {
        System.out.println(formatCurrency(99799.67));
    }


    public static String formatCurrency(double money) {
        String str1 = "";
        Double mon = money;

        String[] str = mon.toString().split("");
        int number = 0;
        for (int i = str.length - 5; i >= 0; i--) {
            number++;
            if (number % 3 == 0) {
                str[i] += ",";
            }

        }
        for (String items : str) {
            str1 += items;
        }


        return str1;
    }
}
